<template>
	<view class="box">
		<view class="banner">
			<swiper class="swiper" indicator-dots="true" autoplay="true" duration="2000" circular="true"
				disable-touch="true">
				<swiper-item v-for="(item, index) in lun" :key="index">
					<image class="img" :src="item.image"></image>
				</swiper-item>
			</swiper>
		</view>

		<view class="list_box" v-for="(item,index) in cate" :key="index">
			<view class="name">{{item.name}}</view>
			<view class="icon_box">
				<view class="info" @click="to(items)" v-for="(items,indexs) in item.list" :key="indexs">
					<image class="icon_img" :src="items.image"></image>
					<view>{{items.title}}</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				lun: [],
				cate: [],
				tel:'',
				user:{}
			}
		},
		onShow() {
			this.getUserInfo();
			this.getCate();
		},
		onLoad(e) {
			if(e.title){
				console.log(e);
				uni.setNavigationBarTitle({
					title:e.title
				})
			}
			this.getLun();
			this.getVal();
		},
		methods: {
			getUserInfo(){
				let token=uni.getStorageSync('userToken');
				if(!token) return;
				
				this.$get(this.$api.userInfo,{token:token},res=>{
					let data=res.data;
					if(data.code==1){
						this.user=data.data;
					}
				});
			},
			setTel(){
				let _=this;
				_.$project.toPhone(_.tel,'物业服务热线');
			},
			getVal(){
				
				this.$get(this.$api.configVal,{name:'tel'},res=>{
					let data=res.data;
					if(data.code==1){
						this.tel=data.data.tel;
					}
				});
				
			},
			
			to(e) {
				
				let _=this;
				this.$needLogin(() => {
					
					
					//_.$project.common(_.user,3);
					
					//if(_.user.audit_status!=2) return;
					
					if(_.user.audit_status==2&&e.url=='/pages/fw/fk/add'){
						
						return _.$project.toast('已认证，请勿预约');
					}
					
					if (e.type == 1) {
						uni.navigateTo({
							url: e.url+'?title='+e.title
						})
					} 
					
					if(e.type==2){
						uni.switchTab({
							url: e.url
						})
					}
					
					if(e.type==3){
						this.setTel();
					}
					
					},3,'/pages/tabar/fw');
				
				
			},
			getCate() {
				this.$get(this.$api.fwHomes, {}, res => {
					let data = res.data;
					if (data.code == 1) {
						this.cate = data.data;
					}
				});
			},
			getLun() {
				this.$get(this.$api.fwLun, {}, res => {
					let data = res.data;
					if (data.code == 1) {
						this.lun = data.data;
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		box-sizing: border-box;
		padding: 20rpx 20rpx 0 20rpx;
	}

	.banner {
		width: 100%;
		height: 300rpx;
		border-radius: 15rpx;
	}

swiper {
		height: 100%;
	}

	.img {
		width: 100%;
		height: 100%;
		border-radius: 15rpx;
	}

	.list_box {
		background-color: white;
		border-radius: 20rpx;
		margin-top: 20rpx;
		box-sizing: border-box;
		padding: 35rpx 0;
	}

	.name {
		font-size: 28rpx;
		font-weight: bold;
		margin-left: 35rpx;
	}

	.icon_box {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.info {
		width: 25%;
		text-align: center;
		margin-top: 35rpx;
		font-size: 26rpx;
		color: black;
	}

	.icon_img {
		width: 80rpx;
		height: 80rpx;
		border-radius: 28rpx;
		margin-bottom: 5rpx;
	}
</style>